package triggerhelper.dataHolders;

import java.io.Serializable;

public class SimpleTrigger implements Serializable {

    protected static final String startCond = "Trigger(\"<Player/Force goes here>\"){ " +
                                              "\nConditions:\n\t";
    protected static final String startAction = "Actions:\n\t";
    protected static final long serialVersionUID = 1L;
    protected String name, fullTrigger, triggerFileName;
    protected boolean isSaved = true, isFileSaved = false;

    public SimpleTrigger(String name_) {
        name = name_;
        fullTrigger = startCond + "\n\n" + startAction;
    }

    @Override
    public String toString() {
        return name + star();
    }
    protected String star() {
        return isSaved ? "" : "*";
    }

    @Override
    public boolean equals(Object o) {
        return (o == null) ? false : ((SimpleTrigger) o).getName().equals(name);
    }

    // <editor-fold defaultstate="collapsed" desc="Getter methods">
    public String getName() {
        return name;
    }public boolean isSimple() {
        return true;
    }public String getFullTrigger(){
        return fullTrigger;
    }public String getTriggerFileName() {
        return triggerFileName;
    }public boolean isSaved() {
        return isSaved;
    }public boolean isFileSaved() {
        return isFileSaved;
    }// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Setter methods">
    public void setFullTrigger(String s){
        if (!fullTrigger.equals(s)) {
            fullTrigger = s;
            isSaved = false;
        }
    }public void setName(String s) {
        if (!name.equals(s)) {
            name = s;
            isSaved = false;
        }
    }public void setTriggerFileName(String s) {
        triggerFileName = s;
    }public void setSaved(boolean b) {
        isSaved = b;
    }public void fileSave() {
        isFileSaved = true;
        isSaved = true;
    }// </editor-fold>

}
